package com.example.hospitalsystem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.hospitalsystem.pojo.dto.pharmacy.UpdateMedicineStockDTO;
import com.example.hospitalsystem.pojo.entity.Pharmacy;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface PharmacyMapper extends BaseMapper<Pharmacy> {

    @Update("update pharmacy set stock_quantity = stock_quantity - #{quantity} where medicine_id = #{medicineId} and stock_quantity > #{quantity}")
    int updateMedicineStock(UpdateMedicineStockDTO updateMedicineStockDTO);

    List<Pharmacy> search(String key);
}
